package ch.fhnw.qualiscan.core;

import ch.fhnw.qualiscan.AppObject;
import ch.fhnw.qualiscan.core.db.HibernateSession;
import ch.fhnw.qualiscan.core.helpers.SessionHelper;
import ch.fhnw.qualiscan.core.helpers.TextHelper;
import ch.fhnw.qualiscan.core.helpers.UserSession;
import ch.fhnw.qualiscan.core.libraries.ModalLib;
import ch.fhnw.qualiscan.core.libraries.UrlLib;

import com.vaadin.ui.Window;

import eu.livotov.tpt.TPTApplication;

@SuppressWarnings("serial")
public class Modal extends Window {

	public SessionHelper sessionHelper;
	public UserSession userSession;
	public TextHelper textHelper;
	public HibernateSession hibernateSession;
	public UrlLib urlLib;
	public ModalLib modalLib;
	
	public Modal() {
		setModalSettings();
		
		modalLib = new ModalLib();
		
		// session
		sessionHelper = new SessionHelper();
		userSession = sessionHelper.getUserSession();
		
		// several helpers
		textHelper = new TextHelper();
		
		hibernateSession = new HibernateSession();
		
		AppObject dataObject = (AppObject) TPTApplication.getCurrentApplication().getMainWindow().getData();
		urlLib = dataObject.getUrlLib();
	}
	
	public void closeModal() {
		modalLib.closeModal();
	}
	
	public void setModalSettings() {
		setModal(true);
		setResizable(false);
		setDraggable(false);
		setWidth("750px");
	
		addListener(new CloseListener() {
			public void windowClose(CloseEvent e) {
				modalLib.closeModal();
			}
		});
	
	}
	
}
